<template>
    <div class="seekersInfo">
        <el-form :model="resumeForm" style="margin-left:300px">
            <el-form-item label="简历名字" style="width:600px">
                <el-input v-model="resumeForm.resume_name"></el-input>
            </el-form-item>
            <el-form-item label="个人优势" style="width:600px">
                <el-input v-model="resumeForm.personal_advantages"></el-input>
            </el-form-item>
            <el-form-item label="工作经历" style="width:600px">
                <el-input v-model="resumeForm.work_experience"></el-input>
            </el-form-item>
            <el-form-item label="项目经历" style="width:600px">
                <el-input v-model="resumeForm.project_experience"></el-input>
            </el-form-item>
        </el-form>
        <div class="resumeUpAndDownload" style="margin-left:-350px">
            <el-button type="primary" @click="doAddResumeInfo">提交简历</el-button>
        </div>

    </div>
</template>
<script>
import axios from 'axios';
export default {
    data() {
        return {
            headers: {
                'X-Auth-Token': window.localStorage.getItem("token")
            },
            resumeForm: {
                personal_advantages: '',
                work_experience: '',
                project_experience: '',
                resume_name: '',
                user: window.localStorage.getItem("user_id"),
            },

        };
    },
    methods: {
        doAddResumeInfo() {
            if (!this.resumeForm.resume_name) {
                this.$message.error("简历名字不能为空!");
                return;
            }
            let that = this;
            axios({
                method: 'post',
                url: 'http://127.0.0.1:5000/api/resume_management/add',
                data: {
                    personal_advantages: that.resumeForm.personal_advantages,
                    work_experience: that.resumeForm.work_experience,
                    project_experience: that.resumeForm.project_experience,
                    user: that.resumeForm.user,
                    resume_name: that.resumeForm.resume_name
                },
                headers: {
                    'X-Auth-Token': window.localStorage.getItem("token")
                },
            })
                .then(function (response) {
                    console.log(response.data);
                    that.$message.success("简历创建成功");
                    that.$router.push({ name: 'resume_list' }, () => { }, () => { });
                })
                .catch(function (error) {
                    console.log(error);
                })
                .then(function () {
                    // 总是会执行
                })
        },
    },
    created: function () {
        if (!window.localStorage.getItem("token")) {
            this.$router.push({ path: '/login' }, () => { }, () => { });
            return;
        }
    }
}
</script>
<style lang="less" scoped>
.seekersInfo {
    margin-top: -400px;
    margin-left: 500px;
    margin-bottom: 200px;
}
</style>